package cn.ejiakanghu.logistics.service;

import cn.com.ejiakanghu.core.exception.CheckException;
import org.linlinjava.litemall.db.domain.AgedmallLgBaseInfo;
import org.linlinjava.litemall.db.domain.AgedmallLgBusiRecord;
import org.linlinjava.litemall.db.domain.AgedmallLgReceiveOrder;
import org.linlinjava.litemall.db.vo.locks.PickUp;
import org.linlinjava.litemall.db.vo.logistics.LogisticsBackUserAddressData;
import org.linlinjava.litemall.db.vo.shop.ChainLockPickup;

import java.util.List;
import java.util.Map;

/**
 * 物流业务基本服务
 */
public abstract class LogisticBusiBaseService {

    public abstract List<Integer> getorderGoodsIds(String lgContent);

    public abstract void insertSignInConfirm(String bigOrderSn,String childOrderCode,Integer userId);

    /**
     * 更新orderGoods状态
     */
    public abstract void updateOrderGoodsStat(String lgContent, Integer state);


    /**
     * 获取当前baseInfo所有rfid
     */
    public abstract Map<String, List<String>> getAllRfidBybaseInfoId(String lgContent);

    /**
     * 新增receive_order表
     */
    public abstract AgedmallLgReceiveOrder insertReceiveOrder(AgedmallLgBaseInfo agedmallLgBaseInfo, Integer deliveryManId,
                                                              Integer receiverType, Integer execType,Long missionId);

    /**
     * 新增busi_record表
     */
    public abstract AgedmallLgBusiRecord insertBusiRecord(Long missionId, Long receiverOrderId, Integer missionType, String orderCode, Integer busiStat);

    /**
     * 新增busi_img
     */
    public abstract void insertBusiImg(Long busiId, Integer imgType, String imgUrls);

    /**
     * 图片转换
     */
    public abstract String base64ToUrl(List<String> base64Img);


    /**
     * 云仓自动配置配货员
     *
     * @param baseInfoId
     * @param missionId
     */
    public abstract void isCloudOrder(Integer baseInfoId, Integer missionId);


    /**
     * 创建任务
     *
     * @param orderCode
     * @param baseInfoId
     * @param type
     */
    public abstract List<Integer> createMission(String orderCode, Integer baseInfoId, Integer type);

    /**
     * 创建任务是否手动，即有管理系统触发
     * @param orderCode
     * @param baseInfoId
     * @param type
     * @param isManual
     * @return
     */
    public abstract List<Integer> createMissionManual(String orderCode, Integer baseInfoId, Integer type, boolean isManual);

    /**
     *
     * @param orderCode
     * @param baseInfoId
     * @param type
     * @return
     */
    public abstract List<Integer> createMissionBackstage(String orderCode, Integer baseInfoId, Integer type);


    /**
     * 用户下单事件
     *
     * @param orderCode  小程序下单单号
     * @param baseInfoId 归属物流id
     * @param type       任务类型
     */
    public abstract List<Integer> userCreateOrderEvent(String orderCode, Integer baseInfoId, Integer type);
    public abstract List<Integer> userCreateOrderEventByManual(String orderCode, Integer baseInfoId, Integer type, boolean isManual, String packageUserId);

    public abstract List<Integer> backstageManagementToPlaceAnOrder(String orderCode, Integer baseInfoId, Integer type);

    /**
     * 配货完成事件
     *
     * @param missionId 任务id
     */
    public abstract List<ChainLockPickup> deployOverEvent(Integer missionId, List<String> imgs, List<PickUp> rfids,String expressCode,List<String> imgUrls,boolean isHospitalSelf) throws CheckException;

    public abstract List<ChainLockPickup> exchangeDeployOverEvent(Integer missionId, List<String> imgs, List<PickUp> rfids, String expressCode, List<String> imgUrls) throws CheckException;

    /**
     * 接单事件 -接单成功-待配送
     *
     * @param manId       接单人id
     * @param missionId   任务id
     * @param messageType takeOrder类型
     */
    public abstract void receiveOrderEvent(Integer manId, Integer missionId, Integer messageType);


    /**
     * 开始配送
     * @param missionId   任务id
     */
    public abstract void startReceiveOrderEvent(Integer missionId) throws CheckException;


    /**
     * 配送完成事件
     *
     * @param missionId
     */
    public abstract void deliveryOverEvent(Integer missionId,List<String> imgs,List<String> imgsUrl);


    /**
     * 换货配送完成事件
     *
     * @param missionId
     */
    public abstract void exchageDeliveryOverEvent(Integer missionId,List<String> imgs,List<String> imgsUrl);

    /**
     * 退货事件
     *
     * @param missionId
     * @param imgs
     */
    public abstract boolean rejectedGoodsEvent(Integer missionId, List<String> imgs);

    /**
     * 拒绝签收
     *
     * @param missionId
     */
    public abstract void refuseGoodsEvent(Integer missionId);


    /**
     * 开始归还-第三方物流
     */
    public abstract  void startReturnGoodsEvent(String bigOrderSn, Integer subOrderId, String expressId, String expressName) throws CheckException;

    /**
     * 归还事件
     */
    public abstract void returnGoodsEvent(Integer missionId);

    /**
     * 维护事件
     */
    public abstract void maintainGoodsEvent(Integer missionId);

    /**
     * 推送用戶消息
     */
    public abstract void userNotice();

    /**
     * 第三方物流送货
     *
     * @param baseInfoId  baseinfo主键id
     * @param expressCode 物流单号
     * @param expressName 物流名称
     */
    public abstract void thirdLogisEvent(Integer baseInfoId, String expressCode, String expressName,Integer takeOrderType) throws CheckException;

    /**
     * 换货事件
     */
    public abstract void exchangeGoodsEvent();


    /**
     * 退货取货完成事件
     *
     * @param missionId
     * @param imgs
     */
    public abstract void returnPickupCompletionEvent(Integer missionId, List<String> imgs);

    /**
     * 换货取货完成事件
     *
     * @param missionId
     * @param imgs
     */
    public abstract void exchangeAcquisitionCompletionEvent(Integer missionId, List<String> imgs);

    /**
     * 换货配货完成事件
     *
     * @param missionId
     * @param imgs
     */
    public abstract void replacementAndDistributionCompletionEvent(Integer missionId, List<String> imgs);

    /**
     * 换货送货完成事件
     *
     * @param missionId
     */
    public abstract void exchangePickUpAndDeliveryCompleted(Integer missionId);

    /**
     * 维护完成事件
     *
     * @param missionId
     * @param imgs
     */
    public abstract void maintenanceCompletionEvent(Integer missionId, List<String> imgs,List<String> imgsUrl);

    /**
     * 归还完成事件
     *
     * @param missionId
     * @param imgs
     */
    public abstract boolean returnCompleteEvent(Integer missionId, List<String> imgs,List<String> imgsUrl);


    /**
     * 取消归还
     */
    public abstract boolean cancelReturn(String orderSn,String childOrderCode);


    /**
     * 检查物流业务处理前订单的基本状态是否满足业务
     * @param bigOrderCode
     * @throws CheckException
     */
    public abstract void checkLgBaseOrderStat(String bigOrderCode) throws CheckException;

}
